package com.init.system.MyTest;

import com.init.system.converter.ApiService;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class RateLimiterDemo {
    public static void main(String[] args) {
        ApiService apiService = new ApiService();
        ExecutorService executor = Executors.newFixedThreadPool(20); // 创建线程池

        // 模拟多线程请求
        for (int i = 0; i < 50; i++) {
            executor.submit(apiService::handleRequest);
            try {
                Thread.sleep(100); // 每200毫秒发起一次请求
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
        executor.shutdown(); // 关闭线程池
    }
}
